#!/bin/bash
ARCH=$(uname -m)

case $ARCH in
x86_64 | aarch64 | ppc64le) LIB_DIR=/usr/lib64
                       SECONDARY_LIB_DIR=/usr/lib
                       ;;
* )
                       LIB_DIR=/usr/lib
                       SECONDARY_LIB_DIR=/usr/lib64
                       ;;
esac

if [ ! -x $LIB_DIR/octave/8.2.0/octave-config-8.2.0 ] ; then
  if [ ! -x $SECONDARY_LIB_DIR/octave/8.2.0/octave-config-8.2.0 ] ; then
    echo "Error: $LIB_DIR/octave/8.2.0/octave-config-8.2.0 not found"
    if [ -d $SECONDARY_LIB_DIR ] ; then
      echo "   and $SECONDARY_LIB_DIR/octave/8.2.0/octave-config-8.2.0 not found"
    fi
    exit 1
  fi
  LIB_DIR=$SECONDARY_LIB_DIR
fi
exec $LIB_DIR/octave/8.2.0/octave-config-8.2.0 "$@"
